<template>
<div>
  <van-field label="用户名" v-model="form.username"></van-field>
  <van-field label="密码" v-model="form.password"></van-field>
  <van-button @click="login">登录</van-button>
</div>
</template>

<script>
import maxios from "../../http/axios";

export default {
  name: "alogin",
  data(){
    return{
      form:{}
    }
  },
  methods:{
    login(){
      maxios('http://127.0.0.1:8000/users/Alogin/','post',this.form)
      .then(i=>{
        if (i.data.code ==200){
          localStorage.setItem('userid',i.data.userid)
          alert('登录成功')
          this.$router.push({path:'/azhu',query:{name:i.data.name}})
        }
        else {
          alert("登录失败")
        }
      })
    }
  },
  mounted() {
  }
}
</script>

<style scoped>

</style>